package gcu.module.property_apply.controller;

import com.sun.xml.internal.ws.api.server.SDDocument;
import gcu.module.property_apply.daomain.PropertyApply;
import gcu.module.property_apply.service.ApplyService;
import gcu.util.Pager;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by haol on 2016/9/24.
 */
@Controller
@RequestMapping("/apply")
public class ApplyController {

      @Autowired
      private ApplyService applyService;

      @RequestMapping("/edit/{id}")
      public String edit(@PathVariable int id,Model model){
            model.addAttribute("id",id);
            applyService.setApplyIsRead(id);
            return "/apply/edit";
      }
      @RequestMapping("/del/{id}")
      public String del(@PathVariable int id){
            applyService.deleteApply(id);
            return "redirect:/apply/list";
      }
      @RequestMapping("/add")
      public String add(Model model){
            model.addAttribute("apply",new PropertyApply());
            return "/apply/edit";
      }
      @RequestMapping("/list")
      public String getApplyList(Model model, PropertyApply apply, Pager pager){
            List<PropertyApply> applies = applyService.queryApplyList(apply, pager);
            model.addAttribute("applyList", applies);
            model.addAttribute("pager", pager);
            return "/apply/list";
      }



}
